public class Solution {
    public int arrangeCoins(int n) {
        return (int)((Math.sqrt(1 + 8.0 * n) - 1) / 2);
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        int n = 8;
        System.out.println(solution.arrangeCoins(n));
    }
}
